package cn.wangxl.vertx.starter.web.session;

import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.auth.AuthProvider;
import io.vertx.ext.auth.User;

/**
 * @Description TODO
 * @Classname UserInfo
 * @Created by wangxl
 * @Date 2020/5/10 10:50
 */
public class UserInfo implements User{

//  public String username;
//
//  public String password;

  public JsonObject user;

  /**
   * 这里依然是通过resultHandle响应授权信息，返回值为当前对象是为了Fluent调用模式
   */
  @Override
  public User isAuthorized(String authority, Handler<AsyncResult<Boolean>> resultHandler) {
    // 一直返回成功
    resultHandler.handle(Future.succeededFuture(true));
    return this;
  }

  @Override
  public User clearCache() {
    return null;
  }

  @Override
  public JsonObject principal() {
    return user;
  }

  @Override
  public void setAuthProvider(AuthProvider authProvider) {

  }
}
